<!DOCTYPE html>
<#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"] />
<html>
<head>
    <meta charset="utf-8">
    <title>飞行试验奖惩项目管理基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <#if isClose == 'true'>
        <style>
            .listBody .qbdms-bodyDiv{padding: 0;background: #fff }
            body.qbdms-particulars .qbdms-bodyDiv div.layui-table-view-body{padding: 16px}
            .layui-form-select .layui-input{padding-right: 0}
        </style>
    </#if>
</head>
<body class="listBody qbdms-particulars">

<div class="qbdms-bodyDiv">
    <div class="layui-table-view-body qbdms-add-view-body">
        <#if isClose != 'true'><div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF">飞行试验奖惩项目信息 <i  class="qbdms-returnOn closeWindow">返回</i></div></#if>
        <form class="formPreview layui-form"  requrl="${ctx}/qbdms/wFlightRewardsProject/get" lay-filter="wFlightRewardsProjectDataForm">
            <div class="" style="width: 100%;overflow-x: auto">
                <table class="tableExcel qbdms-zeroTable" width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr id="tbxx"></tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            飞行试验名称<span style="color: red;">*</span>
                        </td>
                        <td name="flighttestname"></td>
                        <td class="qbdms-zeroTable-lable">
                            密级<span style="color: red;">*</span>
                        </td>
                        <td>
                            <@secSelect.sec_select data_src=1 required=true name="secret"/>
                        </td>
                        <td class="qbdms-zeroTable-lable">
                            年度<span style="color: red;">*</span>
                        </td>
                        <td name="year"></td>
                    </tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            型号名称<span style="color: red;">*</span>
                        </td>
                        <td name="modelname"></td>
                        <td class="qbdms-zeroTable-lable">
                            总体单位名称<span style="color: red;">*</span>
                        </td>
                        <td name="totalityunitname"></td>
                        <td class="qbdms-zeroTable-lable">
                            项目类型<span style="color: red;">*</span>
                        </td>
                        <td name="projecttype"></td>
                    </tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            项目类别<span style="color: red;">*</span>
                        </td>
                        <td name="projectcategory"></td>
                        <td class="qbdms-zeroTable-lable">
                            项目阶段<span style="color: red;">*</span>
                        </td>
                        <td name="projectstage"></td>
                        <td class="qbdms-zeroTable-lable">
                            奖励额度(万元)<span style="color: red;">*</span>
                        </td>
                        <td name="bonusgiven"></td>
                    </tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            处罚额度(万元)<span style="color: red;">*</span>
                        </td>
                        <td name="penaltyamount"></td>
                        <td class="qbdms-zeroTable-lable">
                            产品价格(万元)<span style="color: red;">*</span>
                        </td>
                        <td name="productprice"></td>
                        <td class="qbdms-zeroTable-lable">
                            项目主管部门<span style="color: red;">*</span>
                        </td>
                        <td name="projectdepartment"></td>
                    </tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            是否临时
                        </td>
                        <td name="istemp" colspan="5"></td>
                    </tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            附件
                        </td>
                        <td colspan="5">
                            <div class="uploadFileList" fileUploadName="accessory"></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="qbdms-zeroTable-lable">
                            备注
                        </td>
                        <td name="remark" colspan="5"></td>
                    </tr>
                    </tbody>
                </table>
                <p class="qbdms-SubTableTitle"><span>奖惩金额分配信息</span></p>
                <div class="qbdms-tableDiv">
                    <a modetype="2" class="addFormTr1"
                       id="add"><i class="layui-icon layui-icon-addition"></i>新增</a>
                    <table class="qbdms-temTable wRewardsMoneyAllocationList subFormTable"
                           id="wRewardsMoneyAllocationList" style="min-width: 1360px;">
                        <tbody>
                        <tr class="temSpace qbdms-temTable-thead">
                            <td class="temSpace" style="width: 30px;">
                                序号
                            </td>
                            <td class="temSpace subDialogShowState" style="width: 120px">
                                奖惩单位名称<span style="color: red;">*</span>
                            </td>
                            <td class="temSpace subDialogShowState" style="width: 120px">
                                单位类别<span style="color: red;">*</span>
                            </td>
                            <td class="temSpace subDialogShowState" style="width: 120px">
                                配套关系级别
                            </td>
                            <td class="temSpace subDialogShowState" style="width: 120px">
                                配套产品名称
                            </td>
                            <td class="temSpace subDialogShowState" style="width: 120px">
                                奖惩分配比例<span style="color: red;">*</span>
                            </td>
                        </tr>
                        <tr class="temSpace subContTem">
                            <td class="temSpace qbdms-temTable-seNumber">
                                <div class="temTag">0</div>
                            </td>
                            <td class="temSpace qbdms-temTable-td" name="s:wRewardsMoneyAllocationList:rewardsUnitCodeName"></td>
                            <td class="temSpace qbdms-temTable-td" name="s:wRewardsMoneyAllocationList:unitCategory"></td>
                            <td class="temSpace qbdms-temTable-td" name="s:wRewardsMoneyAllocationList:supportingRelationshipLevel"></td>
                            <td class="temSpace qbdms-temTable-td" name="s:wRewardsMoneyAllocationList:supportingProductsName"></td>
                            <td class="temSpace qbdms-temTable-td" name="s:wRewardsMoneyAllocationList:rewardsAllocationProportion"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <#if isClose != 'true'>
            <div class="layui-form-item btnformItem">
                <p>
                    <button type="reset" id="closeWindow"
                            class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">返回
                    </button>
                </p>
            </div>
        </#if>
            <input type="text" hidden name="year" class="time-init year" />
        </form>
    </div>
</div>

<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'qbdmsForm', 'layer',  'form', 'table',  'propsHandle', 'common', 'laydate', 'jquery','upload','publicMethods'], function () {

        // -----常量声明----------
        var $ = layui.jquery,
            laydate = layui.laydate,
            setter = layui.setter,  // 配置信息
            common = layui.common,
            publicMethods = layui.publicMethods,
            propsHandle = layui.propsHandle,
            form = layui.qbdmsForm,
            formId = '${formDefId}' || '',
            defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        // 子表初始化事件
        temQuery.initSubEvent(defProps, serverPath, setter);

        $(".subContTem").hide();
        var count = 1;
        $(document).on('click', '.addFormTr1', function () {
            count += 1;
            var modetype = $(this).attr('modetype'),
                copyObj = $(this).parent().children('.subFormTable'),
                copyHtm = copyObj.find('tr').eq(1);
            if (modetype === '2') {
                //在这里做一个转换，控制子表隐藏行的必填
                var copyHtmlStr = copyHtm.html();
                copyHtmlStr = copyHtmlStr.replace(/requiredflag/g, "lay-verify");
                // 表格
                copyObj.append('<tr class="temSpace">' + copyHtmlStr + '</tr>');
                var trArr = copyObj.find('tr');
                trArr.eq(trArr.length - 1).find('td').eq(0).find('.temTag').html(trArr.length - 2);

                trArr.eq(trArr.length - 1).find('[isinit="1"]').each(function (i, item) {
                    $(item).attr('isinit', '2');
                });
                if (trArr.length > 3) {
                    trArr.eq(trArr.length - 1).find('[type=radio]').each(function (i, item) {
                        $(item).attr('name', (trArr.eq(1).find('[type=radio]').eq(i).attr('name')) + '_' + (trArr.length - 2))
                    });
                }
                temQuery.initTemEvent(defProps, serverPath, setter);
            } else if (modetype === '1') {
                // updateTr(copyObj, copyHtm);
            }
            form.render();
            lay('.datetime').each(function () {
                laydate.render({
                    elem: this
                    , type: 'year'
                    , trigger: 'click'
                });
            });
            $(".datetime").removeAttr("lay-key");
            publicMethods.bottomFixd()
        });

        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        };

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = '${ctx}/qbdms/wFlightRewardsProject/view/list';
        });

        var runId = "${runId}";
        if(runId == null || runId == ''){
            $("#hideAndShow").show();
        }

        common.updateForm({
            name:'wFlightRewardsProjectDataForm',
            idValue:"${id}",
            primary:"id",
            getCallback:function (data) {
                var returnData = data.data;
                $("#tbxx").html("<td class='qbdms-zeroTable-lable'>填报信息:</td><td colspan='5'>【" + returnData.filldept + " | " + returnData.fillman + " | " + returnData.filldate + "】</td>");

                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);

                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)">' + files[i].fileName + '</span></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            $(this).find("select:last").attr("disabled", "disabled");
                        }
                    }else {
                        $(this).html("<span style='color: #c0c4cc'>未上传</span>");
                    }
                });

                //-修改页面 初始化子表 开始 ------------------------------------------

                $('table.subFormTable').each(function () {

                    var table = {
                        tableName: $(this).attr('class').split(" ")[1],
                        fields: []
                    };
                    table.fields = returnData[table.tableName];
                    if(table.fields.length==0){
                        $(this).parent(".qbdms-tableDiv").append("<p>无数据</p>")
                    }else {
                        $(this).parent(".qbdms-tableDiv").css('padding',"0px")
                    }
                    if(table.fields.length > 0){
                        for (var i = 0, len = table.fields.length; i < len; i++) {
                            var dataRow = table.fields[i];
                            var temp = $("." + table.tableName).prev().click();
                            //这里有子表表头占一行，子表隐藏行占一行，所以取需要赋值的行时，需要temp=i+2
                            var domRow = $(this).find("tr.temSpace:eq(" + (i * 1 + 2) + ")");
                            $.each(dataRow, function (j, val) {
                                var domItem = domRow.find("[name$='" + j + "']");
                                if (domItem) {
                                    domItem.html(val);
                                }
                            });
                        }
                    }
                });

            }
        });

        $("body *").not("#closeWindow").attr("disabled", "disabled");
        $(".uploadFileCont .qbdms-fileUp,.uploadFileCont i,.addFormTr1").hide();
    });
</script>
</body>
</html>